package com.bdf.ipharma.gui;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Vector;

import javax.swing.JPanel;

import com.bdf.ipharma.starter.McdError;

/**
 * A Swing-based panel class.
 * <P>
 * 
 * @author JorgE.H
 */
public class GUIButtonPanel extends JPanel {

   /**
    * Layouts
    */
   GridLayout layoutBase;

   GUIButtonPanel_jButt_actionAdapter buttonAdapter = new GUIButtonPanel_jButt_actionAdapter(
         this);

   /**
    * Attributes
    */
   Vector vButtons = new Vector();

   List vContents;

   GUIOperation myContainer;

   int panelColumns;

   int panelRows;

   /**
    * Constructs a new instance.
    */
   public GUIButtonPanel(GUIOperation pOper, List pContents) {

      super();
      try {
         myContainer = pOper;
         vContents = pContents;
         panelColumns = 4;
         panelRows = 9;
         jbInit();
      } catch (Exception e) {
         McdError.add(e);
      }
   }

   /**
    * Initializes the state of this instance.
    */
   private void jbInit() throws Exception {

      GUIButtonProduct buttonProduct;
      layoutBase = new GridLayout(panelRows, panelColumns, 0, 1);
      int i = 0;
      int l_qty = 0;

      this.setLayout(layoutBase);
      this.setBackground(Colors.APN_BACK);
      String current = "";

      // populate button panel with products or empty, disabled buttons
     
   }

   /**
    * Refreshes all buttons content (retornos al dispenser)
    */
   public void refresh(List pContents) {

      String current = "";
      
   }

   /**
    * Activates all buttons
    */
   public void setAllActive(boolean pActive) {

      for (int i = 0; i < vButtons.size(); i++) {
         GUIButtonProduct l_bp = (GUIButtonProduct) vButtons.elementAt(i);
         l_bp.setActive(pActive);
      }
   }

   /**
    * Activates all buttons that have a zero quantity product
    */
   public void setZeroActive(boolean pActive) {

      
   }

   /**
    * Simulates that the button corresponding to pProd was pushed. This method
    * is called when barcode reader is used.
    * 
    * @param pProd
    *           the Product selected
    */
   public void virtualPushed() {

 
   }

   void jButt_actionPerformed(ActionEvent e) {

      int li_selQty = 0;
      GUIButtonPanel l_panel;
      GUIButtonProduct l_butt;
   }
}

class GUIButtonPanel_jButt_actionAdapter implements
      java.awt.event.ActionListener {

   GUIButtonPanel adaptee;

   GUIButtonPanel_jButt_actionAdapter(GUIButtonPanel adaptee) {

      this.adaptee = adaptee;
   }

   public void actionPerformed(ActionEvent e) {

      adaptee.jButt_actionPerformed(e);
   }
}
